package aer.vaDeModas;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class VaDeModas {

	private static char x;
	private static StringBuilder sb = new StringBuilder("");
	private static List<Integer> list;
	private static int numeros, i, y, cont, z;
	private static Set<Integer> quipu;
	private static StringBuilder sol = new StringBuilder("");

	public static void main(String[] args) throws Exception {
		boolean b = true;

		while (b) {
			numeros = readInt();
			if (numeros <= 0) {
				b = false;
			} else {
				list = new ArrayList<Integer>();

				if (numeros == 0) {
				}
				for (i = 0; i < numeros; i++) {
					list.add(readInt());

				}
				y = 0;
				cont = 0;

				quipu = new HashSet<Integer>(list);
				for (Integer key : quipu) {
					z = Collections.frequency(list, key);
					if (z > cont) {
						cont = z;
						y = key;
					} // fin if
				} // fin for

				sol.append(y + "\n");

			} // fin else
		} // fin while

		System.out.print(sol.toString());
	}

	private static int readInt() throws Exception {
		sb.delete(0, (sb.length()));
		do {
			x = (char) System.in.read();
			if (x != ' ' && x != '\n' && x != '\r') {
				sb.append(x);
			}
		} while (x != ' ' && x != '\n');

		return Integer.parseInt(sb.toString());
	}

}